Вчерашний запрос, "заморозивший" миграцию на три часа:
SELECT entity_id, MAX(start_date), MAX(end_date) FROM ( SELECT entity_id, MAX(start_date) start_date, NULL AS end_date FROM audit_log WHERE attr = 'reviewed' AND newValue = 'true' GROUP BY entity_id UNION ALL SELECT entity_id, NULL AS start_date, MAX(end_date) end_date FROM audit_log WHERE attr = 'overriden' AND newValue = 'true' GROUP BY entity_id ) a GROUP BY entity_id;
можно было бы написать сильно оптимальнее вот так:
SELECT entity_id, MAX(if(attr = 'reviewed', NULL, start_date)) AS start_date, MAX(if(attr = 'reviewed', end_date, NULL)) end_date FROM audit_log WHERE (attr = 'reviewed' OR attr='overriden') AND newValue = 'true' GROUP BY entity_id;
При сильно похожих WHERE в таких конструкциях, удобнее схлопнуть UNION и "на лету" подставлять в SELECT нужное значение через if.
Вчерашний запрос, "заморозивший" миграцию на три часа:
SELECT entity_id, MAX(start_date), MAX(end_date) FROM ( SELECT entity_id, MAX(start_date) start_date, NULL AS end_date FROM audit_log WHERE attr = 'reviewed' AND newValue = 'true' GROUP BY entity_id UNION ALL SELECT entity_id, NULL AS start_date, MAX(end_date) end_date FROM audit_log WHERE attr = 'overriden' AND newValue = 'true' GROUP BY entity_id ) a GROUP BY entity_id;
можно было бы написать сильно оптимальнее вот так:
SELECT entity_id, MAX(if(attr = 'reviewed', NULL, start_date)) AS start_date, MAX(if(attr = 'reviewed', end_date, NULL)) end_date FROM audit_log WHERE (attr = 'reviewed' OR attr='overriden') AND newValue = 'true' GROUP BY entity_id;
При сильно похожих WHERE в таких конструкциях, удобнее схлопнуть UNION и "на лету" подставлять в SELECT нужное значение через if.
BY Developer's mind
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Telegram has made it easier for its users to communicate, as it has introduced a feature that allows more than 200,000 users in a group chat. However, if the users in a group chat move past 200,000, it changes into "Broadcast Group", but the feature comes with a restriction. Groups with close to 200k members can be converted to a Broadcast Group that allows unlimited members. Only admins can post in Broadcast Groups, but everyone can read along and participate in group Voice Chats," Telegram added.
Dump Scam in Leaked Telegram Chat
A leaked Telegram discussion by 50 so-called crypto influencers has exposed the extraordinary steps they take in order to profit on the back off unsuspecting defi investors. According to a leaked screenshot of the chat, an elaborate plan to defraud defi investors using the worthless “$Few” tokens had been hatched. $Few tokens would be airdropped to some of the influencers who in turn promoted these to unsuspecting followers on Twitter.